package com.lwq.util;

import com.lwq.cocos.CCAction;
import com.lwq.cocos.CCDirector;
import com.lwq.cocos.CCLayer;
import com.lwq.cocos.CCMenu;
import com.lwq.cocos.CCNode;
import com.lwq.cocos.CCObject;
import com.lwq.cocos.CCSence;
import com.lwq.cocos.CCSprite;
import com.lwq.model.SuperTableModel;

public class Constance {
	public final static String TRUE_STR = "true";
	public final static String FALSE_STR = "false";
	
	public final static String GET_STR = "get";
	public final static String SET_STR = "set";

	public final static int PROJECT_TYPE_CPP = 1;
	public final static int PROJECT_TYPE_JAVA = 2;
	public final static int PROJECT_TYPE_LUA = 3;
	public final static int PROJECT_TYPE_JS = 4;

	public static int mProjectType = PROJECT_TYPE_CPP;

	public final static int getProjectType() {
		return mProjectType;
	}

	public final static void setProjectType(int mProjectType) {
		Constance.mProjectType = mProjectType;
	}

	public final static String KEY_STR_TYPE = "Type";
	public final static String KEY_STR_CHILDS = "Childs";

	public final static String PREFERENCES_CONFIG_PATH = "config/Preferences_config.json";
	public final static String COCOS_LABLE = "Cocos";
	public final static String DIRECTOR_LABLE = "Director";
	public final static String MENU_LABLE = "Menu";
	public final static String SCENE_LABLE = "Sence";
	public final static String LAYOUT_LABLE = "Layout";
	public final static String SPRITE_LABLE = "Sprite";
	public final static String ACTION_LABLE = "Action";
	public final static String NODE_LABLE = "Node";

	public final static int OBJECT_TYPE = 1;
	public final static int NODE_TYPE = 2;
	public final static int DIRECTOR_TYPE = 3;
	public final static int MENU_TYPE = 4;
	public final static int SCENE_TYPE = 5;
	public final static int LAYOUT_TYPE = 6;
	public final static int SPRITE_TYPE = 7;
	public final static int ACTION_TYPE = 8;
	public final static int PROJECT_TYPE = 9;

	public static Class<?> getCCClass(int type) {
		if (type == OBJECT_TYPE) {
			return CCObject.class;
		} else if (type == NODE_TYPE) {
			return CCNode.class;
		} else if (type == DIRECTOR_TYPE) {
			return CCDirector.class;
		} else if (type == MENU_TYPE) {
			return CCMenu.class;
		} else if (type == SCENE_TYPE) {
			return CCSence.class;
		} else if (type == LAYOUT_TYPE) {
			return CCLayer.class;
		} else if (type == SPRITE_TYPE) {
			return CCSprite.class;
		} else if (type == ACTION_TYPE) {
			return CCAction.class;
		} else {
			return null;
		}
	}

	public static String bracket(String str) {
		return "(" + str + ")";
	}

	public final static String SUPER_TABLE_MODEL_NAME = "superTable";
	public final static String SUPER_TABLE_TEXT_TYPE = "text";
	public final static String SUPER_TABLE_CHOICE_TYPE = "choice";
	public final static String SUPER_TABLE_EXP_TYPE = "exp";

	public static SuperTableModel SuperTableModelNode = null;
	public static SuperTableModel SuperTableModelDirector = null;
	public static SuperTableModel SuperTableModelSprite = null;
	public static SuperTableModel SuperTableModelLayout = null;
	public static SuperTableModel SuperTableModelMenu = null;
	public static SuperTableModel SuperTableModelSence = null;
	public static SuperTableModel SuperTableModelAction = null;

	public static SuperTableModel getSuperTableModel(int type) {
		if (type == NODE_TYPE) {
			if (SuperTableModelNode == null) {
				SuperTableModelNode = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Node.json", SuperTableModel.class);
			}
			return SuperTableModelNode;
		} else if (type == DIRECTOR_TYPE) {
			if (SuperTableModelDirector == null) {
				SuperTableModelDirector = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Director.json", SuperTableModel.class);
			}
			return SuperTableModelDirector;
		} else if (type == SPRITE_TYPE) {
			if (SuperTableModelSprite == null) {
				SuperTableModelSprite = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Sprite.json", SuperTableModel.class);
			}
			return SuperTableModelSprite;
		} else if (type == MENU_TYPE) {
			if (SuperTableModelMenu == null) {
				SuperTableModelMenu = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Menu.json", SuperTableModel.class);
			}
			return SuperTableModelMenu;
		} else if (type == SCENE_TYPE) {
			if (SuperTableModelSence == null) {
				SuperTableModelSence = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Sence.json", SuperTableModel.class);
			}
			return SuperTableModelSence;
		} else if (type == LAYOUT_TYPE) {
			if (SuperTableModelLayout == null) {
				SuperTableModelLayout = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Layout.json", SuperTableModel.class);
			}
			return SuperTableModelLayout;
		} else if (type == ACTION_TYPE) {
			if (SuperTableModelAction == null) {
				SuperTableModelAction = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).FileToModel(
						"res/model/Action.json", SuperTableModel.class);
			}
			return SuperTableModelAction;
		} else {
			return null;
		}
	}

	/**
	 * class
	 */
	public final static Class<?> INTEGER_CLASS = Integer.class;
	public final static Class<?> BOOLEAN_CLASS = Boolean.class;
	public final static Class<?> FLOAT_CLASS = Float.class;
	public final static Class<?> DOUBLE_CLASS = Double.class;
	public final static Class<?> CHARSEQUENCE_CLASS = CharSequence.class;

	/**
	 * Anchor
	 */
	public final static int ANCHOR_TOPLEFT = 1;
	public final static int ANCHOR_TOPRIGHT = 2;
	public final static int ANCHOR_CENTER = 3;
	public final static int ANCHOR_BOTTOMLEFT = 4;
	public final static int ANCHOR_BOTTOMRIGHT = 5;

	public final static String ANCHOR_TOPLEFT_NAME = "topLeft";
	public final static String ANCHOR_TOPRight_NAME = "topRight";
	public final static String ANCHOR_CENTER_NAME = "center";
	public final static String ANCHOR_BOTTOMLEFT_NAME = "bottomLeft";
	public final static String ANCHOR_BOTTONRIGHT_NAME = "bottomRight";

	public static int getAnchor(String anchor) {
		if(anchor == null){
			return 0;
		}else if(anchor.equalsIgnoreCase(ANCHOR_TOPLEFT_NAME)){
			return ANCHOR_TOPLEFT;
		}else if(anchor.equalsIgnoreCase(ANCHOR_TOPRight_NAME)){
			return ANCHOR_TOPRIGHT;
		}else if(anchor.equalsIgnoreCase(ANCHOR_CENTER_NAME)){
			return ANCHOR_CENTER;
		}else if(anchor.equalsIgnoreCase(ANCHOR_BOTTOMLEFT_NAME)){
			return ANCHOR_BOTTOMLEFT;
		}else if(anchor.equalsIgnoreCase(ANCHOR_BOTTONRIGHT_NAME)){
			return ANCHOR_BOTTOMRIGHT;
		}
		return 0;
	}
	
	public static String getAnchorName(int anchor) {
		switch (anchor) {
		case ANCHOR_TOPLEFT:
			return ANCHOR_TOPLEFT_NAME;
		case ANCHOR_TOPRIGHT:
			return ANCHOR_TOPRight_NAME;
		case ANCHOR_CENTER:
			return ANCHOR_CENTER_NAME;
		case ANCHOR_BOTTOMLEFT:
			return ANCHOR_BOTTOMLEFT_NAME;
		case ANCHOR_BOTTOMRIGHT:
			return ANCHOR_BOTTONRIGHT_NAME;
		}
		return null;
	}
	
	
	public static float[] getAnchorScaleValue(int anchor) {
		float [] scale = null;
		switch (anchor) {
		case ANCHOR_TOPLEFT:
			scale = new float[2];
			scale[0] = 0;
			scale[1] = 0;
			return scale;
		case ANCHOR_TOPRIGHT:
			scale = new float[2];
			scale[0] = 1;
			scale[1] = 0;
			return scale;
		case ANCHOR_CENTER:
			scale = new float[2];
			scale[0] = 0.5f;
			scale[1] = 0.5f;
			return scale;
		case ANCHOR_BOTTOMLEFT:
			scale = new float[2];
			scale[0] = 0;
			scale[1] = 1;
			return scale;
		case ANCHOR_BOTTOMRIGHT:
			scale = new float[2];
			scale[0] = 1;
			scale[1] = 1;
			return scale;
		}
		return null;
	}
	
	public final static String THIS_POINT = "this";
	
	/**
	 * postion
	 */
	public final static String SCREEN_WIDTH = "screenWidth";	//屏幕宽度
	public final static String SCREEN_HEIGHT = "screenHeight";	//屏幕高度
	
	/**
	 * scale
	 */
	public final static String FILL_SCREEN = "fillScreen";	//填充屏幕
	
	/**
	 * js
	 */
	public final static String CCIMPROT_JS_PATH = "res/js/CCImporter.js";
	public final static String CCEXP_JS_PATH = "res/js/CCExp.js";
}
